# -*- coding: UTF-8 -*-
# Author: Damon(wuud1)
# CreateDate:
# Message:

import sys
# 解决编码问题
reload(sys)
sys.setdefaultencoding('utf-8')


# a = u'''<partial-response id="j_id1">
# 	<redirect url="/CN/chi/searchresult/49141844220072018034438" />
# </partial-response>'''
# a = '''<?xml version='1.0' encoding='UTF-8'?>
# <partial-response id="j_id1"><redirect url="/CN/chi/searchresult/49141844220072018034438"></redirect></partial-response>'''
#
# from lxml import etree
#
# b = etree.HTML(bytes(a))
# url = b.xpath(u'//redirect/@url')
# print url
#
#
# '''Host: catalog.mann-filter.cn
# Upgrade-Insecure-Requests: 1
# User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
# Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
# Accept-Encoding: gzip, deflate, br
# Accept-Language: zh-CN,zh;q=0.9
# Cookie: anonymousid=8eae8bae-c418-4661-ad61-4ebe69f97187; csfcfc=6n6dQk%2BUejw%3D; JSESSIONID=FA65BC7781186546555F22244734BE87
# Connection: keep-alive'''
from pprint import pprint


# def test(**kwargs):
#     pid = kwargs.get("local_pid", 'xx')
#     print pid
# #
# # test(local_pid="1234")
# # test()
#
# from collections import OrderedDict
# str = 'abcdefghijklmnopqrstuvwxyz'
# for i in str:
#     print i,","


# dict1 = {}
# for i in str:
#     dict1[i] = i
#
# pprint(dict1)
#
# dict2 = {
#     'a': 'a',
#     'b': 'b',
#     'c': 'c',
#     'd': 'd',
#     'e': 'e',
#     'f': 'f',
#     'g': 'g',
#     'h': 'h',
#     'i': 'i',
#     'j': 'j',
#     'k': 'k',
#     'l': 'l',
#     'm': 'm',
#     'n': 'n',
#     'o': 'o',
#     'p': 'p',
#     'q': 'q',
#     'r': 'r',
#     's': 's',
#     't': 't',
#     'u': 'u',
#     'v': 'v',
#     'w': 'w',
#     'x': 'x',
#     'y': 'y',
#     'z': 'z'
# }
#
# for mt in dict2:
#     print mt,
# print ''
#
# dict4 = {
#     'a': 'a',
#     'b': 'b',
#     'c': 'c',
#     'd': 'd',
#     'e': 'e',
#     'f': 'f',
#     'g': 'g',
#     'h': 'h',
#     'i': 'i',
#     'j': 'j',
#     'k': 'k',
#     'l': 'l',
#     'm': 'm',
#     'n': 'n',
#     'o': 'o',
#     'p': 'p',
#     'q': 'q',
#     'r': 'r',
#     's': 's',
#     't': 't',
#     'u': 'u',
#     'v': 'v',
#     'w': 'w',
#     'x': 'x',
#     'y': 'y',
#     'z': 'z'
# }
#
#
# dict3 = OrderedDict(dict4)
#
# for mt in dict3:
#     print mt,



# "Host": "catalog.mann-filter.cn",
# "Connection": "keep-alive",
# "Faces-Request": "partial/ajax",
# "Origin": "https://catalog.mann-filter.cn",
# "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
# "Accept": "*/*",
# "Referer": "",
# "Accept-Encoding": "gzip, deflate, br",
# "Accept-Language": "zh-CN,zh;q=0.9",
# "Cookie": "anonymousid=8eae8bae-c418-4661-ad61-4ebe69f97187; csfcfc=6n6dQk%2BUejw%3D; JSESSIONID=C7B2D140F319A470845B13E9217067DA",
# "Content-Type": "application/x-www-form-urlencoded",

# "productDetail": "productDetail"
# "productDetail": "productDetailTabPanel-value"
# "productDetail": "productDetailCompareTab"
# "javax.faces.ViewState": "4320315975340397687:-882194034507484155"
# "javax.faces.source": "productDetail:j_idt331"
# "javax.faces.partial.execute": "productDetail:j_idt331 @component"
# "javax.faces.partial.render": "@component"
# "name": ""
# "org.richfaces.ajax.component": "productDetail:j_idt331"
# "productDetail:j_idt331": "productDetail:j_idt331"
# "rfExt": "null"
# "AJAX:EVENTS_COUNT": "1"
# "javax.faces.partial.ajax": "true"

# import re
# from lxml import etree
# path = '/Users/duanmengdi/Desktop/workspace/mann_html/'
# file_name = "eacd5a0c71464c729f9d41d7ad22bd37.html"
# with open(path+file_name, 'r') as f:
#     res = f.read()
# html = etree.HTML(res)
#
# name_list = html.xpath('//span[@class="label_lv1"]/text()')
# for name in name_list:
#     print name.decode("utf8")
#
# java = re.findall('ViewState:0"><!\[CDATA\[(.*?)\]\]>', res)
# print java




